package com.qf.oop.hero;

public class Demo02 {
    public static void main(String[] args) {
        LongSword longSword = new LongSword(); // 我在无参构造方法中做了初始化,下同
        longSword.printInfo();

        Dagger dagger = new Dagger();
        dagger.printInfo();

        Hero hero = new Hero();
        hero.setWeapon(longSword);
        System.out.print("长剑攻击伤害为:");
        System.out.println(hero.weaponAttack());

        for (int i = 0; i < 5; i++) {
            hero.setWeapon(dagger);
            System.out.print("匕首攻击伤害为:");
            System.out.println(hero.weaponAttack());
        }



    }

}
